//
//  myView.m
//  spotrs
//
//  Created by xu on 16/5/16.
//  Copyright © 2016年 TZ. All rights reserved.
//

#import "myView.h"
#import "cellOneTableViewCell.h"
#import "MyPointCtrl.h"
#import "myCollectCtrl.h"
@implementation myView
{
    NSArray *nameArray ;
}
-(void)creatView
{
    nameArray = [[NSArray alloc]initWithObjects:@[@"我的积分",@"意见反馈",@"评分",@"分享",@"服务协议",@"我的收藏",@"关于我们"], nil];
    _myTabel = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-navagationgHright-toolbarHright) style:UITableViewStylePlain];
    [_myTabel setBackgroundColor:[UIColor redColor]];
    [_myTabel setSeparatorStyle:UITableViewCellSeparatorStyleSingleLineEtched];
    [_myTabel setDelegate:self];
    [_myTabel setDataSource:self];
    [self addSubview:_myTabel];
    
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
   
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"touxiang"];
        if (!cell) {
            cell = [[UITableViewCell alloc] init];
            [cell setBackgroundColor:[UIColor greenColor]];
            [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
            cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
            //头像
            _touXiangImage = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 45, 45)];
            [_touXiangImage setBackgroundColor:[UIColor redColor]];
            _touXiangImage.layer.masksToBounds = YES;
            _touXiangImage.layer.cornerRadius = 3;
            [cell addSubview:_touXiangImage];
            [cell setRestorationIdentifier:@"touxiang"];
            [_touXiangImage mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(15);
            }];
            //名字
            _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(65, 20, 50, 20)];
            [_nameLabel setText:@"12345"];
            [_nameLabel setFont:[UIFont systemFontOfSize:14]];
            [cell addSubview:_nameLabel];
            
            [_touXiangImage mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(65);
                make.top.mas_equalTo(20);
            }];
            [cell addSubview: [[helpUser sharedInstance] creatLineLabel:[UIColor grayColor]frem:CGRectMake(0, 64, SCREEN_WIDTH, 1)]];
            
        }
        else
        {
            [_nameLabel setText:@"12345"];
        }
        return cell;
    }
    else if(indexPath.row == 2)
    {
        cellOneTableViewCell *cell = (cellOneTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"fenlei1"];
        if (!cell) {
            cell = [[cellOneTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"fenlei1"count:4];
             [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
            
        }
        else
        {
            
        }
        return cell;
    }
    else if(indexPath.row == 1)
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"money"];
        if (!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"money"];
             [cell setBackgroundColor:[UIColor greenColor]];
            UILabel *xianjin = [[UILabel alloc]  initWithFrame:CGRectMake(20, 10, 50, 20)];
            [xianjin setText:@"现金"];
            [xianjin setFont:[UIFont systemFontOfSize:14]];
            [cell addSubview:xianjin];
           
            
            _moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2-80, 10, 80, 20)];
            [_moneyLabel setFont:[UIFont systemFontOfSize:14]];
            [_moneyLabel setText:[NSString stringWithFormat:@"%d.00 元",5]];
            [cell addSubview:_moneyLabel];
            
            UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2, 0, 1, 40)];
            [line setBackgroundColor:[UIColor redColor]];
            [cell addSubview:line];
            
            UILabel *youhui = [[UILabel alloc]  initWithFrame:CGRectMake(SCREEN_WIDTH/2+20, 10, 50, 20)];
            [youhui setText:@"优惠"];
            [youhui setFont:[UIFont systemFontOfSize:14]];
            [cell addSubview:youhui];
            [cell setBackgroundColor:[UIColor grayColor]];
            
            _discountLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-80, 10, 80, 20)];
            [_discountLabel setFont:[UIFont systemFontOfSize:14]];
            [_discountLabel setText:[NSString stringWithFormat:@"%d   张",5]];
            [cell addSubview:_discountLabel];
        }
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        return cell;
    }
    else if(indexPath.row == 3)
    {
        cellOneTableViewCell *cell = (cellOneTableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"fenlei2"];
        if (!cell) {
            cell = [[cellOneTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"fenlei2"count:3];
            [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
            
        }
        else
        {
            
        }
        return cell;
    }
    else
    {
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"other"];
        if (!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"other"];
            [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
            cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
            UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 25, 25)];
            [image setBackgroundColor:[UIColor redColor]];
            [cell addSubview:image];
            
            UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(50, 10, 100, 20)];
            [title setText:[NSString stringWithFormat:@"%ld",indexPath.row]];
            [title setFont:ziTiSize(14)];
            [cell addSubview:title];
            [cell addSubview:[[helpUser sharedInstance] creatLineLabel:[UIColor grayColor] frem:CGRectMake(0, 49, SCREEN_WIDTH, 1)]];
        }
        else
        {
            

        }
        
        return cell;
    }

    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        return 64;
    }
    else if (indexPath.row == 1)
    {
        return 40;
    }
    else if (indexPath.row == 2)
    {
        return 122;
    }
    else if (indexPath.row == 3)
    {
        return 122;
    }
    else
    {
        return 50;
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 4) {
        MyPointCtrl *mypoint = [[MyPointCtrl alloc]init];
        [theApp pushController:mypoint];
    }
    
    if (indexPath.row == 9) {
        myCollectCtrl *mycollect = [[myCollectCtrl alloc]init];
        [theApp pushController:mycollect];
    }
}

@end
